package com.nuoniu.sibanyun.service.crm.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nuoniu.sibanyun.entity.crm.CrmSysField;
import com.nuoniu.sibanyun.mapper.crm.CrmSysFieldMapper;
import com.nuoniu.sibanyun.service.crm.ICrmSysFieldService;
import com.nuoniu.sibanyun.userThread.UserInfo;
import com.nuoniu.sibanyun.userThread.UserThreadLocal;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 系统字段 服务实现类
 * </p>
 *
 * @author baiqiang
 * @since 2020-06-15
 */
@Service
public class CrmSysFieldServiceImpl extends ServiceImpl<CrmSysFieldMapper, CrmSysField> implements ICrmSysFieldService {

    @Override
    public Page<CrmSysField> getCrmSysFieldPage(Page page, String source) {
        UserInfo userInfo = UserThreadLocal.get();
        CrmSysField crmSysField = new CrmSysField();
        QueryWrapper<CrmSysField> queryWrapper = new QueryWrapper<>(crmSysField);
        queryWrapper.eq("source", source);
        queryWrapper.eq("company_id", userInfo.getCompanyId());
        queryWrapper.orderByAsc("sort");
        return page(page, queryWrapper);
    }
}
